home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / appleman / evtprog3.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  2.0 KB  |  71 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Event sample #2"
  4.    ClientHeight    =   3720
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   5940
  8.    Height          =   4125
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3720
  12.    ScaleWidth      =   5940
  13.    Top             =   1140
  14.    Width           =   6060
  15.    Begin TextBox Text4 
  16.       Height          =   375
  17.       Left            =   300
  18.       TabIndex        =   4
  19.       Top             =   2340
  20.       Width           =   1815
  21.    End
  22.    Begin TextBox Text3 
  23.       Height          =   375
  24.       Left            =   300
  25.       TabIndex        =   2
  26.       Top             =   1800
  27.       Width           =   1815
  28.    End
  29.    Begin TextBox Text2 
  30.       Height          =   375
  31.       Left            =   300
  32.       TabIndex        =   1
  33.       Text            =   "600"
  34.       Top             =   1200
  35.       Width           =   1815
  36.    End
  37.    Begin TextBox Text1 
  38.       Height          =   435
  39.       Left            =   300
  40.       TabIndex        =   0
  41.       Top             =   540
  42.       Width           =   1815
  43.    End
  44.    Begin Label Label1 
  45.       Caption         =   "Enter #>500 and press tab."
  46.       Height          =   255
  47.       Left            =   2220
  48.       TabIndex        =   3
  49.       Top             =   600
  50.       Width           =   3015
  51.    End
  52. Option Explicit
  53. ' An infinite loop can be created as each control
  54. ' fails its valid condition and attempts to set
  55. ' the focus back to itself.
  56. Sub Text1_LostFocus ()
  57.     If Val(Text1.Text) > 500 Then Text1.SetFocus
  58. End Sub
  59. Sub Text2_LostFocus ()
  60.     If Val(Text2.Text) > 500 Then Text2.SetFocus
  61. End Sub
  62. ' A stack space overflow can be created when
  63. ' a change in one control causes a change in
  64. ' a second control.
  65. Sub Text3_Change ()
  66.     text4.Text = Str$(Val(text4.Text) + 1)
  67. End Sub
  68. Sub Text4_Change ()
  69.     text3.Text = Str$(Val(text3.Text) + 1)
  70. End Sub
  71.